package com.lufei.message_system.Controller;

import com.lufei.message_system.Data.MbtiTypeDescriptionVD.*;
import com.lufei.message_system.Data.PageResult;
import com.lufei.message_system.Data.Result;
import com.lufei.message_system.Service.MbtiTypeDescriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/mbti_type_description")
public class MbtiTypeDescriptionController {

    @Autowired
    private MbtiTypeDescriptionService service;

    // 创建MBTI类型描述
    @PostMapping
    public Result create(@RequestBody MbtiTypeDescriptionCreateDTO createDTO) {
        return service.createMbtiTypeDescription(createDTO);
    }

    // 删除MBTI类型描述
    @DeleteMapping("/{mbtiType}")
    public Result delete(@PathVariable String mbtiType) {
        return service.deleteMbtiTypeDescription(mbtiType);
    }

    // 更新MBTI类型描述
    @PutMapping("/{mbtiType}")
    public Result update(
            @PathVariable String mbtiType,
            @RequestBody MbtiTypeDescriptionUpdateDTO updateDTO) {
        return service.updateMbtiTypeDescription(mbtiType, updateDTO);
    }

    // 获取单个MBTI类型描述详情
    @GetMapping("/{mbtiType}")
    public Result<MbtiTypeDescriptionVO> getMbtiTypeDescription(@PathVariable String mbtiType) {
        return service.getMbtiTypeDescription(mbtiType);
    }

    // 查询MBTI类型描述列表（支持分页和模糊查询）
    @GetMapping
    public Result<PageResult<MbtiTypeDescriptionVO>> listMbtiTypeDescriptions(
            @RequestParam(defaultValue = "1") Integer page,
            @RequestParam(defaultValue = "10") Integer size,
            MbtiTypeDescriptionQueryDTO queryDTO) {
        return service.listMbtiTypeDescriptions(page, size, queryDTO);
    }
}